package com.cyzy.controller;

import com.cyzy.dto.Result;
import com.cyzy.pojo.Course;
import com.cyzy.pojo.CourseCategory;
import com.cyzy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zxw
 * @create 2025-06-04 上午10:19
 */
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;

    //查询课程信息
    @RequestMapping("/selectCourse")
    private Result selectCourse(@RequestParam("campusId") String campusId,
                                @RequestParam(name = "categoryId", required = false) String categoryId){
        System.out.println("接收到的参数: campusId=" + campusId + ", categoryId=" + categoryId);
        List<Course> list = courseService.selectCourse(campusId,categoryId);
        return Result.ok().data("list",list);
    }

    //查询课程类别
    @RequestMapping("/selectCourseCategory")
    private Result selectCourseCategory(@RequestParam("campusId") String campusId){
        List<CourseCategory> list = courseService.selectCourseCategory(campusId);
        return Result.ok().data("list",list);
    }
}
